package com.xzj.admin.resource.sync.service.impl;

import com.xzj.admin.resource.sync.domain.vo.SelectOption;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import com.xzj.common.datasource.domain.PageReq;
import com.xzj.common.datasource.domain.PageResp;
import com.xzj.common.datasource.utils.XzjPageUtil;
import com.xzj.admin.resource.sync.domain.entity.ResMessageTarget;
import com.xzj.admin.resource.sync.mapper.ResMessageTargetMapper;
import com.xzj.admin.resource.sync.service.ResMessageTargetService;

import java.util.List;

/**
 * @program: xzj-admin
 * @ClassName: ResMessageTargetServiceImpl
 * @description: 资源消息目标端;(res_message_target)表服务实现类
 * @author: XiaZunJun
 * @create: 2024-10-31
 */
@Service
public class ResMessageTargetServiceImpl implements ResMessageTargetService{
    @Resource
    private ResMessageTargetMapper resMessageTargetMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param targetId 主键
     * @return 实例对象
     */
    public ResMessageTarget queryById(String targetId){
        return resMessageTargetMapper.queryById(targetId);
    }

    /**
     * 分页查询
     *
     * @param pageReq 分页筛选条件对象
     * @return 查询结果
     */
    public PageResp<ResMessageTarget> pageQuery(PageReq<ResMessageTarget> pageReq){
        return XzjPageUtil.queryPage(pageReq, resMessageTarget -> resMessageTargetMapper.pageQuery(resMessageTarget));
    }

    /**
     * 新增数据
     *
     * @param resMessageTarget 实例对象
     * @return 实例对象
     */
    public ResMessageTarget insert(ResMessageTarget resMessageTarget){
        resMessageTargetMapper.insert(resMessageTarget);
        return resMessageTarget;
    }

    /**
     * 更新数据
     *
     * @param resMessageTarget 实例对象
     * @return 实例对象
     */
    public ResMessageTarget update(ResMessageTarget resMessageTarget){
        resMessageTargetMapper.update(resMessageTarget);
        return resMessageTarget;
    }

    /**
     * 通过主键删除数据
     *
     * @param targetId 主键
     * @return 是否成功
     */
    public boolean deleteById(String targetId){
        int total = resMessageTargetMapper.deleteById(targetId);
        return total > 0;
    }

    @Override
    public List<SelectOption> queryAll() {
        return resMessageTargetMapper.queryAll();
    }
}